<?php

/**
 * @file
 * This file contains the main theme functions hooks and overrides.
 */
//
///**
// * Override or insert variables into the maintenance page template.
// */
//function adminimal_preprocess_maintenance_page(&$vars) {
//  // While markup for normal pages is split into page.tpl.php and html.tpl.php,
//  // the markup for the maintenance page is all in the single
//  // maintenance-page.tpl.php template. So, to have what's done in
//  // adminimal_preprocess_html() also happen on the maintenance page, it has to be
//  // called here.
//  adminimal_preprocess_html($vars);
//}
//
/**
 * Override or insert variables into the html template.
 */
function junashare_v1_preprocess_html(&$vars) {
  // Fix the viewport and zooming in mobile devices.
  $viewport = array(
    '#tag' => 'meta',
    '#attributes' => array(
      'name' => 'viewport',
      'content' => 'width=device-width, maximum-scale=1, minimum-scale=1, user-scalable=no, initial-scale=1',
    ),
  );
  drupal_add_html_head($viewport, 'viewport');

//  Fix meta for bootstrap
  $system_meta_content_type = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
      'http-equiv' => 'X-UA-Compatible',
      'content' => 'IE=edge',
    ),
    '#weight' => -1000,
  );
  drupal_add_html_head($system_meta_content_type, 'system_meta_content_type');

  $utf8 = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
      'charset' => 'utf-8',
    ),
    '#weight' => -1001,
  );
  drupal_add_html_head($utf8, 'utf8');
}

/**
 * Implementation of hook_preprocess_page().
 * @param $variables
 */
function junashare_v1_preprocess_page(&$variables) {
  if (isset($variables['node']->type)) {
    $variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type;
  }
}

/**
 * Display the list of available node types for node creation.
 */
//function adminimal_node_add_list($variables) {
//  $content = $variables['content'];
//  $output = '';
//  if ($content) {
//    $output = '<ul class="admin-list">';
//    foreach ($content as $item) {
//      $output .= '<li class="clearfix">';
//      $output .= '<span class="label">' . l($item['title'], $item['href'], $item['localized_options']) . '</span>';
//      $output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>';
//      $output .= '</li>';
//    }
//    $output .= '</ul>';
//  }
//  else {
//    $output = '<p>' . t('You have not created any content types yet. Go to the <a href="@create-content">content type creation page</a> to add a new content type.', array('@create-content' => url('admin/structure/types/add'))) . '</p>';
//  }
//  return $output;
//}
//
///**
// * Implements theme_adminimal_block_content().
// *
// * Use unordered list markup in both compact and extended mode.
// */
//function adminimal_adminimal_block_content($variables) {
//  $content = $variables['content'];
//  $output = '';
//  if (!empty($content)) {
//    $output = system_adminimal_compact_mode() ? '<ul class="admin-list compact">' : '<ul class="admin-list">';
//    foreach ($content as $item) {
//      $output .= '<li class="leaf">';
//      $output .= l($item['title'], $item['href'], $item['localized_options']);
//      if (isset($item['description']) && !system_adminimal_compact_mode()) {
//        $output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>';
//      }
//      $output .= '</li>';
//    }
//    $output .= '</ul>';
//  }
//  return $output;
//}
//
///**
// * Implements theme_tablesort_indicator().
// *
// * Use our own image versions, so they show up as black and not gray on gray.
// */
//function adminimal_tablesort_indicator($variables) {
//  $style = $variables['style'];
//  $theme_path = drupal_get_path('theme', 'adminimal');
//  if ($style == 'asc') {
//    return theme('image', array('path' => $theme_path . '/images/arrow-asc.png', 'alt' => t('sort ascending'), 'width' => 13, 'height' => 13, 'title' => t('sort ascending')));
//  }
//  else {
//    return theme('image', array('path' => $theme_path . '/images/arrow-desc.png', 'alt' => t('sort descending'), 'width' => 13, 'height' => 13, 'title' => t('sort descending')));
//  }
//}
//
///**
// * Implements hook_css_alter().
// */
//function adminimal_css_alter(&$css) {
//  // Use Seven's vertical tabs style instead of the default one.
//  if (isset($css['misc/vertical-tabs.css'])) {
//    $css['misc/vertical-tabs.css']['data'] = drupal_get_path('theme', 'adminimal') . '/css/vertical-tabs.css';
//  }
//  if (isset($css['misc/vertical-tabs-rtl.css'])) {
//    $css['misc/vertical-tabs-rtl.css']['data'] = drupal_get_path('theme', 'adminimal') . '/css/vertical-tabs-rtl.css';
//  }
//  // Use Seven's jQuery UI theme style instead of the default one.
//  if (isset($css['misc/ui/jquery.ui.theme.css'])) {
//    $css['misc/ui/jquery.ui.theme.css']['data'] = drupal_get_path('theme', 'adminimal') . '/css/jquery.ui.theme.css';
//  }
//}
//
///**
// * Implements hook_js_alter().
// */
//function adminimal_js_alter(&$javascript) {
//  // Fix module filter available updates page.
//  if (isset($javascript[drupal_get_path('module','module_filter').'/js/update_status.js'])) {
//    $javascript[drupal_get_path('module','module_filter').'/js/update_status.js']['data'] = drupal_get_path('theme', 'adminimal') . '/js/update_status.js';
//  }
//}
//
///**
// * Implements theme_admin_block().
// * Adding classes to the administration blocks see issue #1869690.
// */
//function adminimal_admin_block($variables) {
//  $block = $variables['block'];
//  $output = '';
//
//  // Don't display the block if it has no content to display.
//  if (empty($block['show'])) {
//    return $output;
//  }
//
//  if (!empty($block['path'])) {
//    $output .= '<div class="admin-panel ' . check_plain(str_replace("/", " ", $block['path'])) . ' ">';
//  }
//  elseif (!empty($block['title'])) {
//    $output .= '<div class="admin-panel ' . check_plain(strtolower($block['title'])) . '">';
//  }
//  else {
//    $output .= '<div class="admin-panel">';
//  }
//
//  if (!empty($block['title'])) {
//    $output .= '<h3 class="title">' . $block['title'] . '</h3>';
//  }
//
//  if (!empty($block['content'])) {
//    $output .= '<div class="body">' . $block['content'] . '</div>';
//  }
//  else {
//    $output .= '<div class="description">' . $block['description'] . '</div>';
//  }
//
//  $output .= '</div>';
//
//  return $output;
//}
//
///**
// * Implements theme_admin_block_content().
// * Adding classes to the administration blocks see issue #1869690.
// */
//function adminimal_admin_block_content($variables) {
//  $content = $variables['content'];
//  $output = '';
//
//  if (!empty($content)) {
//    $class = 'admin-list';
//    if ($compact = system_admin_compact_mode()) {
//      $class .= ' compact';
//    }
//    $output .= '<dl class="' . $class . '">';
//    foreach ($content as $item) {
//      if (!isset($item['path'])) {
//          $item['path']='';
//      }
//      $output .= '<div class="admin-block-item ' . check_plain(str_replace("/", "-", $item['path'])) . '"><dt>' . l($item['title'], $item['href'], $item['localized_options']) . '</dt>';
//      if (!$compact && isset($item['description'])) {
//        $output .= '<dd class="description">' . filter_xss_admin($item['description']) . '</dd>';
//      }
//      $output .= '</div>';
//    }
//    $output .= '</dl>';
//  }
//  return $output;
//}
//
///**
// * Implements theme_table().
// */
//function adminimal_table($variables) {
//  $header = $variables['header'];
//  $rows = $variables['rows'];
//  $attributes = $variables['attributes'];
//  $caption = $variables['caption'];
//  $colgroups = $variables['colgroups'];
//  $sticky = $variables['sticky'];
//  $empty = $variables['empty'];
//
//  // Add sticky headers, if applicable.
//  if (count($header) && $sticky) {
//    drupal_add_js('misc/tableheader.js');
//    // Add 'sticky-enabled' class to the table to identify it for JS.
//    // This is needed to target tables constructed by this function.
//    $attributes['class'][] = 'sticky-enabled';
//  }
//
//  $output = '<div class="overflow-fix">';
//  $output .= '<table' . drupal_attributes($attributes) . ">\n";
//
//  if (isset($caption)) {
//    $output .= '<caption>' . $caption . "</caption>\n";
//  }
//
//  // Format the table columns:
//  if (count($colgroups)) {
//    foreach ($colgroups as $number => $colgroup) {
//      $attributes = array();
//
//      // Check if we're dealing with a simple or complex column
//      if (isset($colgroup['data'])) {
//        foreach ($colgroup as $key => $value) {
//          if ($key == 'data') {
//            $cols = $value;
//          }
//          else {
//            $attributes[$key] = $value;
//          }
//        }
//      }
//      else {
//        $cols = $colgroup;
//      }
//
//      // Build colgroup
//      if (is_array($cols) && count($cols)) {
//        $output .= ' <colgroup' . drupal_attributes($attributes) . '>';
//        $i = 0;
//        foreach ($cols as $col) {
//          $output .= ' <col' . drupal_attributes($col) . ' />';
//        }
//        $output .= " </colgroup>\n";
//      }
//      else {
//        $output .= ' <colgroup' . drupal_attributes($attributes) . " />\n";
//      }
//    }
//  }
//
//  // Add the 'empty' row message if available.
//  if (!count($rows) && $empty) {
//    $header_count = 0;
//    foreach ($header as $header_cell) {
//      if (is_array($header_cell)) {
//        $header_count += isset($header_cell['colspan']) ? $header_cell['colspan'] : 1;
//      }
//      else {
//        ++$header_count;
//      }
//    }
//    $rows[] = array(array(
//      'data' => $empty,
//      'colspan' => $header_count,
//      'class' => array('empty', 'message'),
//    ));
//  }
//
//  // Format the table header:
//  if (count($header)) {
//    $ts = tablesort_init($header);
//    // HTML requires that the thead tag has tr tags in it followed by tbody
//    // tags. Using ternary operator to check and see if we have any rows.
//    $output .= (count($rows) ? ' <thead><tr>' : ' <tr>');
//    foreach ($header as $cell) {
//      $cell = tablesort_header($cell, $header, $ts);
//      $output .= _theme_table_cell($cell, TRUE);
//    }
//    // Using ternary operator to close the tags based on whether or not there are rows
//    $output .= (count($rows) ? " </tr></thead>\n" : "</tr>\n");
//  }
//  else {
//    $ts = array();
//  }
//
//  // Format the table rows:
//  if (count($rows)) {
//    $output .= "<tbody>\n";
//    $flip = array(
//      'even' => 'odd',
//      'odd' => 'even',
//    );
//    $class = 'even';
//    foreach ($rows as $number => $row) {
//      // Check if we're dealing with a simple or complex row
//      if (isset($row['data'])) {
//        $cells = $row['data'];
//        $no_striping = isset($row['no_striping']) ? $row['no_striping'] : FALSE;
//
//        // Set the attributes array and exclude 'data' and 'no_striping'.
//        $attributes = $row;
//        unset($attributes['data']);
//        unset($attributes['no_striping']);
//      }
//      else {
//        $cells = $row;
//        $attributes = array();
//        $no_striping = FALSE;
//      }
//      if (count($cells)) {
//        // Add odd/even class
//        if (!$no_striping) {
//          $class = $flip[$class];
//          $attributes['class'][] = $class;
//        }
//
//        // Build row
//        $output .= ' <tr' . drupal_attributes($attributes) . '>';
//        $i = 0;
//        foreach ($cells as $cell) {
//          $cell = tablesort_cell($cell, $header, $ts, $i++);
//          $output .= _theme_table_cell($cell);
//        }
//        $output .= " </tr>\n";
//      }
//    }
//    $output .= "</tbody>\n";
//  }
//
//  $output .= "</table>\n";
//  $output .= "</div>\n";
//  return $output;
//}
